<template>
  <el-dialog
    v-model="dialogFormVisible"
    :title="CustomerInfo.CustomerAllName"
    fullscreen
    width="1500px"
    top="0vh"
    @close="close"
  >
    <el-row :gutter="20">
      <el-col :span="5">
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="客户信息"
            :column="3"
            :size="size"
            border
          >
            <template #extra>
              <el-button class="card-header-tag" type="primary" size="small">
                证照信息
              </el-button>
            </template>
          </el-descriptions>
          <div>
            <p>
              <el-text style="color: #999">客户ID：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.CustomerID }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">客户全称：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.CustomerAllName }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">所属区域：</el-text>
              <el-text style="color: #333">{{ CustomerInfo.CityShow }}</el-text>
            </p>
            <p>
              <el-text style="color: #999">地址：</el-text>
              <el-text style="color: #333">{{ CustomerInfo.Address }}</el-text>
            </p>
            <p>
              <el-text style="color: #999">电话：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.Telphone }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">法定代表人：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.LegalPerson }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">业务联系人：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.BusinessPerson }}
                {{ CustomerInfo.BusinessPersonMobile }}
              </el-text>
            </p>
          </div>
          <el-divider />
          <div>
            <p>
              <el-text style="color: #999">客户所在行业：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.IndustryShow }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主营产品：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.SalesProducts }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主要销售区域：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.SalesArea }}
              </el-text>
            </p>
            <p>
              <el-text style="color: #999">主要客户群体：</el-text>
              <el-text style="color: #333">
                {{ CustomerInfo.CustomerGroup }}
              </el-text>
            </p>
          </div>
        </el-card>
      </el-col>
      <el-col :span="19">
        <!-- <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="客户基本信息"
            :column="4"
            :size="size"
            border
          >
            <template #extra>
              <el-button type="primary">查看更多信息</el-button>
            </template>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">客户全称</div>
              </template>
              {{ CustomerInfo.CustomerAllName }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">所属区域</div>
              </template>
              {{ CustomerInfo.City }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">所属行业</div>
              </template>
              {{ CustomerInfo.Industry }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">电话</div>
              </template>
              {{ CustomerInfo.Telphone }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">法定代表人</div>
              </template>
              {{ CustomerInfo.LegalPerson }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">负责人电话</div>
              </template>
              {{ CustomerInfo.LegalMobile }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">业务联系人</div>
              </template>
              {{ CustomerInfo.BusinessPerson }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">业务联系人电话</div>
              </template>
              {{ CustomerInfo.BusinessPersonMobile }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">主营产品</div>
              </template>
              {{ CustomerInfo.SalesProducts }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">主要销售区域</div>
              </template>
              {{ CustomerInfo.SalesArea }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">主要客户群体</div>
              </template>
              {{ CustomerInfo.CustomerGroup }}
            </el-descriptions-item>
            <el-descriptions-item>
              <template #label>
                <div class="cell-item">地址</div>
              </template>
              {{ CustomerInfo.Address }}
            </el-descriptions-item>
          </el-descriptions>
        </el-card> -->
        <el-card shadow="hover">
          <el-row>
            <el-col style="text-align: center" :span="4">
              <el-statistic
                title="被挑入数量"
                :value="CustomerCount.CustomerPickCount"
              />
            </el-col>
            <el-col style="text-align: center" :span="4">
              <el-statistic
                title="跟进中商机数量"
                :value="CustomerCount.TrackingBusinessCount"
              />
            </el-col>
            <el-col style="text-align: center" :span="4">
              <el-statistic
                title="已签合同数量"
                :value="CustomerCount.BusinessOrderCount"
              />
            </el-col>
            <el-col style="text-align: center" :span="4">
              <el-statistic
                title="业务产品数量"
                :value="CustomerCount.OrderProductCount"
              />
            </el-col>
            <el-col style="text-align: center" :span="4">
              <el-statistic
                title="业务赠品数量"
                :value="CustomerCount.OrderGiftCount"
              />
            </el-col>
          </el-row>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="跟进中商机"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="primary"
                size="small"
                plain
                @click="TrackRecord"
              >
                跟进中的跟进小记
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            :data="TrackingBusinessOrders"
            style="width: 100%; margin-bottom: 20px"
            row-key="OrderID"
            default-expand-all
          >
            <el-table-column prop="OrderID" label="商机ID" width="90" />
            <el-table-column prop="BusinessOrderName" label="商机业务类" />
            <el-table-column prop="SaleStaffName" label="跟进人" />
            <el-table-column align="center" label="跟进小记" width="200">
              <template #default="{ row }">
                <el-button
                  class="card-header-tag"
                  type="primary"
                  size="small"
                  @click="getCustomerTrack(row, [0])"
                >
                  跟进小记
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下业务合同"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="primary"
                size="small"
                plain
                @click="TrackRecord"
              >
                已签单的跟进小记
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            :data="BusinessOrders"
            style="width: 100%; margin-bottom: 20px"
            row-key="id"
            default-expand-all
          >
            <el-table-column prop="OrderID" label="合同ID" width="80" />
            <el-table-column
              prop="SignOrderDate"
              label="签单日期"
              width="120"
            />
            <el-table-column
              prop="BusinessOrderName"
              label="商机业务类"
              width="180"
            />
            <el-table-column prop="OrderCode" label="合同编号" width="150" />
            <el-table-column prop="SaleStaffName" label="签单人" />
            <el-table-column prop="OrderTypeName" label="合同属性" />
            <el-table-column prop="OrderTotalMoney" label="合同金额" />
            <el-table-column prop="ReserveMoney" label="备付金金额" />
            <el-table-column prop="OrderMemo" label="备注" width="250" />
            <el-table-column align="center" label="跟进小记" width="100">
              <template #default="{ row }">
                <el-button
                  class="card-header-tag"
                  type="primary"
                  size="small"
                  @click="getCustomerTrack(row, [0])"
                >
                  跟进小记
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" label="收款记录" width="100">
              <template #default="{ row }">
                <el-button
                  class="card-header-tag"
                  type="primary"
                  size="small"
                  @click="getOrderPaymentList(row)"
                >
                  收款记录
                </el-button>
              </template>
            </el-table-column>
            <el-table-column align="center" label="开票信息" width="100">
              <template #default="{ row }">
                <el-button
                  class="card-header-tag"
                  type="primary"
                  size="small"
                  @click="getOrderInvoicingList(row)"
                >
                  开票信息
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <!-- <div style="height: 50px"></div> -->
        <!-- <el-divider>名下业务产品</el-divider> -->
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下业务产品"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="primary"
                size="small"
                @click="TrackRecord"
              >
                服务小记
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="OrderProductList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="合同ID"
              prop="OrderID"
              width="80"
            />
            <el-table-column
              align="center"
              label="业务ID"
              prop="OrderListID"
              width="80"
            />
            <el-table-column
              align="center"
              label="产品名称"
              prop="ProductName"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="产品价格"
              prop="ProductPrice"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="产品数量"
              prop="ProductNum"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="产品签约金额"
              prop="ProductMoney"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="成本金额"
              prop="ProductCost"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="服务对象"
              show-overflow-tooltip
            >
              <template #default="{ row }">
                <a :href="row.StoreUrl" target="_blank">
                  {{ row.BindStoreAccount }}
                </a>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="实际服务期限"
              show-overflow-tooltip
              width="250"
            >
              <template #default="{ row }">
                {{ row.ServiceStartDate }} 至 {{ row.ServiceEndDate }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="服务小记" width="100">
              <template #default="{ row }">
                <el-button
                  class="card-header-tag"
                  type="primary"
                  size="small"
                  @click="getCustomerTrack(row, [1, 2, 3])"
                >
                  服务小记
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下业务赠品"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="primary"
                size="small"
                @click="TrackRecord"
              >
                服务小记
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="OrderGiftList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="合同ID"
              prop="OrderID"
              width="80"
            />
            <el-table-column
              align="center"
              label="业务ID"
              prop="OrderListID"
              width="80"
            />
            <el-table-column
              align="center"
              label="产品名称"
              prop="ProductName"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="产品价格"
              prop="ProductPrice"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="产品数量"
              prop="ProductNum"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="产品签约金额"
              prop="ProductMoney"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="成本金额"
              prop="ProductCost"
              show-overflow-tooltip
            />
            <el-table-column
              align="center"
              label="服务对象"
              show-overflow-tooltip
            >
              <template #default="{ row }">
                <a :href="row.StoreUrl" target="_blank">
                  {{ row.BindStoreAccount }}
                </a>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="实际服务期限"
              show-overflow-tooltip
              width="250"
            >
              <template #default="{ row }">
                {{ row.ServiceStartDate }} 至 {{ row.ServiceEndDate }}
              </template>
            </el-table-column>
            <el-table-column align="center" label="服务小记" width="100">
              <template #default="{ row }">
                <el-button
                  class="card-header-tag"
                  type="primary"
                  size="small"
                  @click="getCustomerTrack(row, [1, 2, 3])"
                >
                  服务小记
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <!-- <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下服务对象"
            :column="3"
            :size="size"
            border
          >
            <template #extra>
              <el-button
                class="card-header-tag"
                type="success"
                size="small"
                @click="CustomerHandle"
              >
                更多详情
              </el-button>
            </template>
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="StoreList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="服务对象ID"
              prop="StoreID"
              show-overflow-tooltip
              width="120"
            />
            <el-table-column
              align="center"
              prop="ProductName"
              label="服务产品或赠品"
            />
            <el-table-column
              align="center"
              prop="StoreAccount"
              label="服务对象"
            />
            <el-table-column align="center" label="是否工厂店" width="130">
              <template #default="{ row }">
                <span v-if="row.isFactory == 0">否</span>
                <span v-if="row.isFactory == 1">是</span>
              </template>
            </el-table-column>
            <el-table-column align="center" label="链接" width="70">
              <template #default="{ row }">
                <div v-if="row.StoreUrl">
                  <a :href="row.StoreUrl" target="_blank">链接</a>
                </div>
                <div v-else>--</div>
              </template>
            </el-table-column>
            <el-table-column align="center" label="操作" width="200">
              <template #default="{ row }">
                <el-button
                  v-if="row.isLock"
                  type="success"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
                <el-button
                  v-else
                  type="danger"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card> -->
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下域名"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="success"
                size="small"
                @click="CustomerHandle"
              >
                更多详情
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="DomainList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="域名ID"
              prop="DomainID"
              show-overflow-tooltip
              width="120"
            />
            <el-table-column align="center" label="域名" width="200">
              <template #default="{ row }">
                <a :href="'http://www.' + row.Domain" target="_blank">
                  {{ row.Domain }}
                </a>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              prop="DomainType"
              label="域名类型"
            />
            <el-table-column align="center" prop="Supplier" label="供应商" />
            <el-table-column align="center" prop="Servicer" label="原服务商" />
            <el-table-column align="center" prop="RegDate" label="注册日期" />
            <el-table-column align="center" prop="ExpDate" label="到期日期" />
            <el-table-column align="center" prop="Memo" label="备注" />
            <el-table-column align="center" label="操作" width="200">
              <template #default="{ row }">
                <el-button
                  v-if="row.isLock"
                  type="success"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
                <el-button
                  v-else
                  type="danger"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下虚拟主机"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="success"
                size="small"
                @click="CustomerHandle"
              >
                更多详情
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="HostList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="主机ID"
              prop="HostID"
              show-overflow-tooltip
              width="120"
            />
            <el-table-column align="center" prop="HostName" label="主机名称" />
            <el-table-column align="center" prop="HostSize" label="主机大小" />
            <el-table-column align="center" prop="HostType" label="主机类型" />
            <el-table-column align="center" prop="Supplier" label="供应商" />
            <el-table-column align="center" prop="Servicer" label="原服务商" />
            <el-table-column align="center" prop="RegDate" label="注册日期" />
            <el-table-column align="center" prop="ExpDate" label="到期日期" />
            <el-table-column align="center" prop="Memo" label="备注" />
            <el-table-column align="center" label="操作" width="200">
              <template #default="{ row }">
                <el-button
                  v-if="row.isLock"
                  type="success"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
                <el-button
                  v-else
                  type="danger"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下邮箱"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="success"
                size="small"
                @click="CustomerHandle"
              >
                更多详情
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="EmailList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="邮箱ID"
              prop="EmailID"
              show-overflow-tooltip
              width="120"
            />
            <el-table-column align="center" prop="EmailName" label="邮箱名称" />
            <el-table-column align="center" prop="EmailSize" label="邮箱大小" />
            <el-table-column align="center" prop="Supplier" label="供应商" />
            <el-table-column align="center" prop="Servicer" label="原服务商" />
            <el-table-column align="center" prop="RegDate" label="注册日期" />
            <el-table-column align="center" prop="ExpDate" label="到期日期" />
            <el-table-column align="center" prop="Memo" label="备注" />
            <el-table-column align="center" label="操作" width="200">
              <template #default="{ row }">
                <el-button
                  v-if="row.isLock"
                  type="success"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
                <el-button
                  v-else
                  type="danger"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
        <el-card shadow="hover">
          <el-descriptions
            class="margin-top"
            title="名下网站"
            :column="3"
            :size="size"
            border
          >
            <!-- <template #extra>
              <el-button
                class="card-header-tag"
                type="success"
                size="small"
                @click="CustomerHandle"
              >
                更多详情
              </el-button>
            </template> -->
          </el-descriptions>
          <el-table
            v-loading="listLoading"
            :data="WebSiteList"
            @selection-change="setSelectRows"
          >
            <el-table-column
              align="center"
              label="域名ID"
              prop="WebSiteID"
              show-overflow-tooltip
              width="120"
            />
            <el-table-column align="center" prop="Domain" label="域名" />
            <el-table-column
              align="center"
              prop="DomainType"
              label="域名类型"
            />
            <el-table-column align="center" prop="Supplier" label="供应商" />
            <el-table-column align="center" prop="Memo" label="备注" />
            <el-table-column align="center" label="操作" width="200">
              <template #default="{ row }">
                <el-button
                  v-if="row.isLock"
                  type="success"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
                <el-button
                  v-else
                  type="danger"
                  size="small"
                  @click="handleEdit(row)"
                >
                  查看账密
                </el-button>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
    <domain ref="domainRef" @fetch-data="EmitData" />
    <host ref="hostRef" @fetch-data="EmitData" />
    <server ref="serverRef" @fetch-data="EmitData" />
    <email ref="emailRef" @fetch-data="EmitData" />
    <website ref="websiteRef" @fetch-data="EmitData" />
    <StoreLink ref="storeLinkRef" @fetch-data="EmitData" />
    <TrackRecord ref="recordRef" @fetch-data="fetchData" />
    <el-dialog
      v-model="paymentDialog"
      title="开票信息"
      width="1400px"
      top="3vh"
    >
      <payment-list ref="paymentRef" @fetch-data="fetchData" />
    </el-dialog>
    <el-dialog
      v-model="invoicingDialog"
      title="开票信息"
      width="1300px"
      top="3vh"
    >
      <invoicing-list ref="invoicingRef" @fetch-data="fetchData" />
    </el-dialog>
  </el-dialog>
</template>

<script>
  import { AllInfo } from '@/api/common'
  import Domain from '@/views/business/components/Domain'
  import Host from '@/views/business/components/Host'
  import Server from '@/views/business/components/Server'
  import Email from '@/views/business/components/Email'
  import { showPassword } from '@/api/businessOrder'
  import TrackRecord from '@/views/business/components/TrackRecord'
  import Website from '@/views/business/components/Website'
  import StoreLink from '@/views/business/components/StoreLink'
  import PaymentList from '@/views/business/components/PaymentList'
  import InvoicingList from '@/views/business/components/InvoicingList'

  export default defineComponent({
    name: 'CustomerAllInfo',
    components: {
      StoreLink,
      Domain,
      Host,
      Server,
      Email,
      Website,
      TrackRecord,
      PaymentList,
      InvoicingList,
    },
    emits: ['fetch-data'],
    setup(props, { emit }) {
      const $baseMessage = inject('$baseMessage')

      const state = reactive({
        recordRef: null,
        storeLinkRef: null,
        websiteRef: null,
        emailRef: null,
        hostRef: null,
        serverRef: null,
        domainRef: null,
        paymentRef: null,
        invoicingRef: null,
        BusinessOrders: [],
        CustomerCount: {},
        CustomerPicks: [],
        CustomerInfo: {},
        formRef: null,
        queryForm: {},
        OrderList: [],
        StoreList: [],
        DomainList: [],
        HostList: [],
        EmailList: [],
        ServerList: [],
        WebSiteList: [],
        OrderProductList: [],
        OrderGiftList: [],
        rules: {
          title: [{ required: true, trigger: 'blur', message: '请输入标题' }],
        },
        title: '',
        dialogFormVisible: false,
        paymentDialog: false,
        invoicingDialog: false,
      })

      const showEdit = (row) => {
        console.log(row, 'row')

        state.queryForm = Object.assign({}, row)
        getInfo(row)
        state.dialogFormVisible = true
      }
      const close = () => {
        state.queryForm = {}
        state.dialogFormVisible = false
      }
      const getInfo = async (row) => {
        let CustomerPickID
        if (row.CustomerPickID) {
          CustomerPickID = row.CustomerPickID
        } else {
          CustomerPickID = 0
        }
        const dataMsg = {
          CustomerID: row.CustomerID,
          CustomerPickID: CustomerPickID,
        }
        const {
          data: {
            CustomerInfo,
            CustomerPicks,
            CustomerCount,
            TrackingBusinessOrders,
            BusinessOrders,
            OrderProductList,
            OrderGiftList,
            StoreList,
            DomainList,
            HostList,
            EmailList,
            ServerList,
            WebSiteList,
          },
        } = await AllInfo(dataMsg)
        state.TrackingBusinessOrders = TrackingBusinessOrders
        state.BusinessOrders = BusinessOrders
        state.CustomerCount = CustomerCount
        state.CustomerInfo = CustomerInfo
        state.CustomerPicks = CustomerPicks
        state.OrderProductList = OrderProductList
        state.OrderGiftList = OrderGiftList
        state.StoreList = StoreList
        state.DomainList = DomainList
        state.HostList = HostList
        state.EmailList = EmailList
        state.ServerList = ServerList
        state.WebSiteList = WebSiteList
      }
      const save = async () => {
        const { msg } = await doTrusteeship(state.form)
        $baseMessage(msg, 'success', 'vab-hey-message-success')
        emit('fetch-data')
        close()
      }
      const getCustomerTrack = (row, t) => {
        const order = {
          CustomerPickID: row.CustomerPickID,
          OrderID: row.OrderID,
          TrackClass: t,
          OrderListID: row.OrderListID,
        }
        state.recordRef.handleEdit(order)
      }

      const getOrderPaymentList = (row) => {
        state.paymentDialog = true
        nextTick(() => {
          state.paymentRef.showList(row, row.PaymentList)
        })
      }
      const getOrderInvoicingList = (row) => {
        state.invoicingDialog = true
        nextTick(() => {
          state.invoicingRef.showList(row, row.InvoicingList, row.PaymentList)
        })
      }
      const handleEdit = async (row) => {
        console.log('shopLinkForm', row)
        const businessClass = row.BusinessClassID
        // state.BusinessClassID = row.BusinessClassID
        switch (businessClass) {
          case 1:
            if (row.BindID != 0 && row.isLock) {
              if (await open(row)) {
                state.storeLinkRef.showEdit(row, true, true)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, true)
            }
            break
          case 2:
            if (row.BindID != 0 && row.isLock) {
              if (await open(row)) {
                state.storeLinkRef.showEdit(row, true, true)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, true)
            }
            break
          case 3:
            if (row.BindID != 0 && row.isLock) {
              if (await open(row)) {
                state.storeLinkRef.showEdit(row, true, true)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, true)
            }
            break
          case 4:
            if (row.BindID != 0 && row.isLock) {
              if (await open(row)) {
                state.storeLinkRef.showEdit(row, true, true)
              }
            } else {
              state.storeLinkRef.showEdit(row, true, true)
            }
            break
          case 5:
            if (row.ProductID == 63) {
              if (row.BindID != 0 && row.isLock) {
                if (await open(row)) {
                  state.domainRef.showEdit(row, true, true)
                }
              } else {
                state.domainRef.showEdit(row, true, true)
              }
            } else if (row.ProductID == 64) {
              if (row.BindID != 0 && row.isLock) {
                if (await open(row)) {
                  state.hostRef.showEdit(row, true, true)
                }
              } else {
                state.hostRef.showEdit(row, true, true)
              }
            } else if (row.ProductID == 65) {
              if (row.BindID != 0 && row.isLock) {
                if (await open(row)) {
                  state.serverRef.showEdit(row, true, true)
                }
              } else {
                state.serverRef.showEdit(row, true, true)
              }
            } else if (row.ProductID == 67) {
              if (row.BindID != 0 && row.isLock) {
                if (await open(row)) {
                  state.emailRef.showEdit(row, true, true)
                }
              } else {
                state.emailRef.showEdit(row, true, true)
              }
            } else if (
              row.ProductID == 68 ||
              row.ProductID == 69 ||
              row.ProductID == 70 ||
              row.ProductID == 107 ||
              row.ProductID == 108
            ) {
              if (row.BindID != 0 && row.isLock) {
                if (await open(row)) {
                  state.websiteRef.showEdit(row, true, true)
                }
              } else {
                state.websiteRef.showEdit(row, true, true)
              }
            } else {
              if (row.BindID != 0 && row.isLock) {
                if (await open(row)) {
                  state.storeLinkRef.showEdit(row, true, true)
                }
              } else {
                state.storeLinkRef.showEdit(row, true, true)
              }
            }
            break
          default:
            if (row.BindID != 0 && row.isLock) {
              if (await open(row)) {
                state.storeLinkRef.showEdit(row, true, true)
              }
            } else {
              state.storeLinkRef.showEdit(row, false, true)
            }
        }
        // 域名的63
        // state.domainRef.showEdit(row)
        // 主机的64
        // state.hostRef.showEdit(row)
        // 邮箱的67
        // state.emailRef.showEdit(row)
        // 网站 68,69,70,107.108
        // state.websiteRef.showEdit(row)
      }

      const open = async (row) => {
        let flag
        await ElMessageBox.prompt('请输入密码', '', {
          confirmButtonText: '确认',
          cancelButtonText: '关闭',
        })
          .then(async ({ value }) => {
            const dataMsg = {
              StoreID: row.StoreID,
              ShowPassword: value,
            }
            const { data } = await showPassword(dataMsg)
            console.log(data, typeof data)

            if (data) {
              flag = true
            } else {
              flag = false
              ElMessage({
                type: 'warning',
                message: `密码输入错误`,
              })
            }
          })
          .catch(() => {
            flag = false
          })
        return flag
      }

      return {
        ...toRefs(state),
        showEdit,
        getInfo,
        handleEdit,
        open,
        close,
        save,
        getCustomerTrack,
        getOrderPaymentList,
        getOrderInvoicingList,
      }
    },
  })
</script>
